package cn.tedu.mm.admin.section.controller;


import cn.tedu.mm.admin.section.pojo.vo.AdminIndexInfoVO;
import cn.tedu.mm.admin.section.pojo.vo.IndexInfoVO;
import cn.tedu.mm.admin.section.server.AdminIndexServer;
import cn.tedu.mm.common.pojo.authentication.CurrentPrincipal;
import cn.tedu.mm.common.web.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/admin")
public class AdminIndexController {

    @Autowired
    AdminIndexServer server;

    /**
     * 页面展示信息
     */
    @GetMapping("/info")
    public JsonResult index() {
        IndexInfoVO indexInfoVO = server.indexInfo();
        return JsonResult.ok(indexInfoVO);
    }

    /**
     * 管理员个人信息
     */
    @GetMapping("/adminInfo")//
    public JsonResult adminInfo(@AuthenticationPrincipal CurrentPrincipal principal) {
        //Long id = principal.getId();
        AdminIndexInfoVO adminInfo =server.adminInfo(1L);
        return JsonResult.ok(adminInfo);
    }
}
